package com.demo.service.cin.impl;

import com.demo.dao.cin.entity.CinApplicationItem;
import com.demo.dao.cin.mapper.*;
import com.demo.dao.cin.model.CinAlarmNodeVO;
import com.demo.dao.cin.model.CinDataIoNodeVO;
import com.demo.dao.cin.model.CinProjectTreeItemVO;
import com.demo.dao.cin.model.CinVariableNodeVO;
import com.demo.service.cin.CinBasicVOService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class CinBasicVOServiceImpl implements CinBasicVOService {
    @Autowired
    private CinApplicationMapper applicationMapper;

    @Autowired
    private CinProjectTreeVOMapper projectTreeVOMapper;

    @Autowired
    private CinVariableNodeVOMapper variableNodeVOMapper;

    @Autowired
    private CinDataIoNodeVOMapper dataIoNodeVOMapper;

    @Autowired
    private CinAlarmNodeVOMapper alarmNodeVOMapper;

    //查询应用配置信息
    @Override
    public List<CinApplicationItem> getApplicationList() {
        return applicationMapper.selectAll();
    }

    //项目页面树
    @Override
    public List<CinProjectTreeItemVO> getProjectVOTreeById(Long id) {
        return projectTreeVOMapper.getProjectVOTreeById(id);
    }

    //变量表
    @Override
    public PageInfo<CinVariableNodeVO> getVariableNodeVO(Map<String, String> map, Integer pageNum, Integer pageSize) {
        List<CinVariableNodeVO> lists;
        PageInfo<CinVariableNodeVO> pageInfo;

        // TODO Auto-generated method stub
        PageHelper.startPage(pageNum, pageSize);

        lists = variableNodeVOMapper.getVariableNodeVO(map);
        pageInfo = new PageInfo<CinVariableNodeVO>(lists);

        return pageInfo;
    }

    //io列表
    @Override
    public PageInfo<CinDataIoNodeVO> getDataIoNodeVO(Map<String, String> map, Integer pageNum, Integer pageSize) {
        List<CinDataIoNodeVO> lists;
        PageInfo<CinDataIoNodeVO> pageInfo;

        // TODO Auto-generated method stub
        PageHelper.startPage(pageNum, pageSize);

        lists = dataIoNodeVOMapper.getDataIoNodeVO(map);
        pageInfo = new PageInfo<CinDataIoNodeVO>(lists);

        return pageInfo;
    }


    //报警列表
    @Override
    public PageInfo<CinAlarmNodeVO> getAlarmNodeVO(Map<String, String> map, Integer pageNum, Integer pageSize) {
        List<CinAlarmNodeVO> lists;
        PageInfo<CinAlarmNodeVO> pageInfo;

        // TODO Auto-generated method stub
        PageHelper.startPage(pageNum, pageSize);

        lists = alarmNodeVOMapper.getAlarmNodeVO(map);
        pageInfo = new PageInfo<CinAlarmNodeVO>(lists);

        return pageInfo;
    }

}
